package logic

import (
	"github.com/gin-gonic/gin"
	"github.com/vueadmin/app/admin/internal/dto"
	"github.com/vueadmin/app/admin/internal/model"
	"github.com/vueadmin/app/admin/internal/service"
	"github.com/vueadmin/app/admin/internal/svc"
	"github.com/vueadmin/app/admin/internal/vo"
)

type goodsLogic struct{
	ctx    *gin.Context
	svcCtx *svc.ServiceContext
}

func NewGoodsLogic(ctx *gin.Context, svcCtx *svc.ServiceContext) *goodsLogic {
	return &goodsLogic{
		ctx: ctx,
		svcCtx: svcCtx,
	}
}

/**
 * @description(数据列表)
 * @buildcode(true)
*/
func (p goodsLogic) GetPageList(req *dto.GoodsPageReq) ([]*vo.GoodsList, int64, error) {
	s := service.NewGoodsService(p.svcCtx)
	return s.GetPageList(req)
}

/**
 * @description(修改排序开关)
 * @buildcode(true)
*/
func (p goodsLogic) UpdateExt(req map[string]interface{}) error {
	s := service.NewGoodsService(p.svcCtx)
	return s.UpdateExt(req)
}

/**
 * @description(添加)
 * @buildcode(true)
*/
func (p goodsLogic) Add(req *dto.GoodsAddReq) (int, error) {
	s := service.NewGoodsService(p.svcCtx)
	return s.Add(req)
}

/**
 * @description(修改)
 * @buildcode(true)
*/
func (p goodsLogic) Update(req *dto.GoodsUpdateReq) error {
	s := service.NewGoodsService(p.svcCtx)
	return s.Update(req)
}

/**
 * @description(获取修改详情)
 * @buildcode(true)
*/
func (p goodsLogic) GetUpdateInfo(req *dto.GoodsGetUpdateInfoReq) (*model.Goods, error) {
	s := service.NewGoodsService(p.svcCtx)
	return s.GetUpdateInfo(req)
}

/**
 * @description(删除)
 * @buildcode(true)
*/
func (p goodsLogic) Delete(req *dto.GoodsDeleteReq) error {
	s := service.NewGoodsService(p.svcCtx)
	return s.Delete(req)
}

/**
 * @description(查看详情)
 * @buildcode(true)
*/
func (p goodsLogic) Detail(req *dto.GoodsDetailReq) (*vo.GoodsDetail, error) {
	s := service.NewGoodsService(p.svcCtx)
	return s.Detail(req)
}

/**
 * @description(查询sql下拉字段列表)
 * @buildcode(true)
*/
func (p goodsLogic) GetFieldList(c *gin.Context) (map[string]interface{}, error) {
	s := service.NewGoodsService(p.svcCtx)
	return s.GetFieldList(p.ctx)
}

/**
 * @description(查询所属分类联动)
 * @buildcode(true)
*/
func (p goodsLogic) GetClassIdList(req *dto.GoodsClassIdReq) ([]*vo.GoodsClassId, error) {
	s := service.NewGoodsService(p.svcCtx)
	return s.GetClassIdList(req)
}

